<?php
    session_start();
    
    $conn = mysql_connect('vergil.u.washington.edu:10000','root','445db');
    if(!$conn) {
        echo 'Could not connect to database. Please try again later.',"<br>";
    }
    
    $current_db = mysql_select_db('test',$conn);
    if (!$current_db) {
        echo 'User verification unavailable. Please try again later.',"<br>";
    }
    
    $user = $_POST["usr"];
    
    //echo $user,"<br>\n";
    
    $result = mysql_query("SELECT * FROM login");
    if(!$result) {
        echo 'User verification unavailable. Please try again later.',"<br>";
    }
    
    while($row=mysql_fetch_row($result)){
        if($_POST["usr"]==$row[0] && $_POST["pass"]==$row[1]){
            //echo 'Login Successful.';
            $_SESSION['key']='check';
            header("Location: https://staff.washington.edu/jamarq/home.php");
            exit;
            break;
        }
    }
    $_SESSION['key']='fail';
    header("Location: https://staff.washington.edu/jamarq/index.html");
    exit;

?>